//This entity is from CM team
package entity.tx;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToMany;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Temporal;

import java.util.Date;
import javax.persistence.Column;

/**
 * 
 * @author Vic
 */
@Entity
public class Users implements Serializable {
   
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO) 
    private Long id;
    
    //************************************************************************************
    //THE DATAFIELDS USED BY SOCIAL/MOBILE TEAM
    //************************************************************************************
    @Column(unique=true, length=128)
    private String email;

    @Temporal(javax.persistence.TemporalType.DATE)
    private Date birthDate;
    
    @OneToOne(cascade = {CascadeType.PERSIST})
    private Country country;
    
    private Long createdTime;

    //************************************************************************************
    //THE DATAFIELDS USED BY TRANSACTION TEAM
    //************************************************************************************
    
    private Integer loyaltypoint;
    
    @Temporal(javax.persistence.TemporalType.TIMESTAMP)
    private Date expirydate; 
    @Temporal(javax.persistence.TemporalType.TIMESTAMP)
    private Date mostRecentTransactionDate;
    @OneToOne
    private CustomerTier customerTier;
    @OneToMany  (cascade = {CascadeType.ALL}, mappedBy="customer" )
    private List<OutletReservation> reservations = new ArrayList<OutletReservation>();
    @ManyToMany 
    private List <GroupBuyingItem> groupBuy = new ArrayList<GroupBuyingItem>();

    @OneToMany ( cascade = {CascadeType.ALL} )
    private List<RewardVoucher> list_vouchers = new ArrayList<RewardVoucher>();
    
    @OneToMany ( cascade = {CascadeType.ALL} )
    private List<TransactionEntry> list_transactionEntry = new ArrayList<TransactionEntry>();
    
    @OneToMany (cascade={CascadeType.ALL})
    private List<PointsPurchaseRecord> pointsPurchaseLog = new ArrayList<PointsPurchaseRecord>();
    
    //-------------------------------------------------------------------------------------------------------------------
    
     public Users(){
        createdTime = new Date().getTime();
    } //no-arg onstructor
    
    
    public Integer getLoyaltypoint() {
        return loyaltypoint;
    }


    public void setLoyaltypoint(Integer loyaltypoint) {
        this.loyaltypoint = loyaltypoint;
    }


    public Date getExpirydate() {
        return expirydate;
    }


    public void setExpirydate(Date expirydate) {
        this.expirydate = expirydate;
    }


    public Date getMostRecentTransactionDate() {
        return mostRecentTransactionDate;
    }


    public void setMostRecentTransactionDate(Date mostRecentTransactionDate) {
        this.mostRecentTransactionDate = mostRecentTransactionDate;
    }


    public CustomerTier getCustomerTier() {
        return customerTier;
    }


    public void setCustomerTier(CustomerTier customerTier) {
        this.customerTier = customerTier;
    }


    public List<OutletReservation> getReservations() {
        return reservations;
    }


    public void setReservations(List<OutletReservation> reservations) {
        this.reservations = reservations;
    }
    
    public void addReservation(OutletReservation or){
        this.reservations.add(or);
    }

    //END transaction team datafields
    //************************************************************************************
    //************************************************************************************

    
    
    //get and set methods
    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public Date getBirthDate() {
        return birthDate;
    }

    public void setBirthDate(Date birthDate) {
        this.birthDate = birthDate;
    }

    public List <GroupBuyingItem> getGroupBuy() {
        return groupBuy;
    }

    public void setGroupBuy(List <GroupBuyingItem> groupBuy) {
        this.groupBuy = groupBuy;
    }

    public List<RewardVoucher> getList_vouchers() {
        return list_vouchers;
    }

    public void setList_vouchers(List<RewardVoucher> list_vouchers) {
        this.list_vouchers = list_vouchers;
    }

    public List<TransactionEntry> getList_transactionEntry() {
        return list_transactionEntry;
    }

    public void setList_transactionEntry(List<TransactionEntry> list_transactionEntry) {
        this.list_transactionEntry = list_transactionEntry;
    }

    public List<PointsPurchaseRecord> getPointsPurchaseLog() {
        return pointsPurchaseLog;
    }

    public void setPointsPurchaseLog(List<PointsPurchaseRecord> pointsPurchaseLog) {
        this.pointsPurchaseLog = pointsPurchaseLog;
    }

    public Country getCountry() {
        return country;
    }

    public void setCountry(Country country) {
        this.country = country;
    }

    public Long getCreatedTime() {
        return createdTime;
    }

    public void setCreatedTime(Long createdTime) {
        this.createdTime = createdTime;
    }

}
